package bavaria.hightech.money;

public class Money {

	private long value;
	private Currency currency;

	public Money(long value, Currency curr) {
		this.value = value;
		this.currency = curr;
	}

	public float getChangeRate() {
		float w = currency.getWechselkurs();
		return w;
	}

	public long getValue() {
		return this.value;
	}
	
	public boolean equals(Money money){
		if(this.currency == money.getCurrency() && this.value == money.getValue())
		return true;
		else
		return false;
	}
	
	public Money addMoney(Money add) {

		if (checkCurrency(add.currency))
			this.value += add.value;
		else

			this.value += (add.value * add.getChangeRate());

		return new Money(this.value, this.currency);

	}

	public Money subtMoney(Money sub) {
		if (checkCurrency(sub.currency))
			this.value -= sub.value;
		else

			this.value -= (sub.value * sub.getChangeRate());
		return new Money(this.value, this.currency);
	}

	public boolean checkCurrency(Currency addCurr) {
		if (this.currency == addCurr)
			return true;
		else
			return false;
	}
	
	public Currency getCurrency(){
		return this.currency;
	}

//	 public static void main(String[] args){
//	
//	 Money meinGeld = new Money(1000, Currency.EURO);
//	 meinGeld.addMoney(new Money(125, Currency.EURO));
//	
////	 meinGeld.subtMoney(new Money(400, Currency.EURO));
//	
//	 System.out.println(meinGeld.getWechselkurs());
//	 System.out.println(meinGeld.value);
//	
//	
//	
//	
//	 }
}
